home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Personal Computer World 2009 February
/
PCWFEB09.iso
/
Software
/
Resources
/
Chat & Communication
/
Digsby build 37
/
digsby_setup.exe
/
lib
/
jabber
/
JabberChat.pyo
(
.txt
)
< prev
next >
Wrap
Python Compiled Bytecode
|
2008-10-13
|
7KB
|
177 lines
# Source Generated with Decompyle++
# File: in.pyo (Python 2.5)
from util import tag_parse, tag, callsback
import pyxmpp.jabber.muc as pyxmpp
from pyxmpp.message import Message
import common.Conversation as common
from util.observe import Observable
from common import get_bname, Conversation
from pyxmpp.all import JID
from logging import getLogger
log = getLogger('JabberChat')
from pprint import pformat
class JabberChatBuddy(Observable):
def __init__(self, mucRoomUser, room):
Observable.__init__(self)
self.user = mucRoomUser
self.room = room
def __getattr__(self, val, default = sentinel):
val = getattr(self.user, val, default)
if val is sentinel:
return object.__getattribute__(self, val, default)
else:
return val
name = property((lambda self: self.user.nick))
def service(self):
return self.room.protocol.name
service = property(service)
def idstr(self):
return u'/'.join([
self.service,
self.room.name,
self.name])
def alias(self):
return self.user.nick
alias = property(alias)
def __repr__(self):
user = self.user
if not user.real_jid:
pass
return '<JabberChatBuddy %s [%s %s] (Real JID: %s)>' % (user.room_jid, user.role, user.affiliation, '?')
class JabberChat(pyxmpp.jabber.muc.MucRoomHandler, Conversation):
ischat = True
def __init__(self, protocol, jid):
Conversation.__init__(self)
self.jid = jid
self.protocol = protocol
self.protocol.conversations[jid.as_unicode()] = self
self.buddies = { }
def name(self):
name = self.room_state.room_jid.bare()
subject = self.room_state.subject
if subject:
return u'%s - %s' % (name, subject)
else:
return unicode(name)
name = property(name)
def user_joined(self, user, stanza):
bud = self._buddy(user)
self.room_list.append(bud)
log.info('user %r joined:\n%s', bud, pformat(list(self.room_list)))
def user_left(self, user, stanza):
bud = self.buddies[user.nick]
self.room_list.remove(bud)
log.info('user %r left:\n%s', bud, pformat(list(self.room_list)))
def nick_changed(self, user, old_nick, stanza):
b = self._buddy(user)
b.notify('name', old_nick, b.name)
def affiliation_changed(self, user, old_aff, new_aff, stanza):
self._buddy(user).notify('affiliation', old_aff, new_aff)
def role_changed(self, user, old_role, new_role, stanza):
self._buddy(user).notify('role', old_role, new_role)
def subject_changed(self, user, stanza):
self.notify('name', None, self.room_state.subject)
def message_received(self, user, stanza):
self.incoming_message(self._buddy(user), stanza.get_body())
def incoming_message(self, buddy, message):
self.typing_status[buddy] = None
self.received_message(buddy, message)
def room_configuration_error(self, stanza):
self.error(stanza)
def error(self, stanza):
err = stanza.get_error()
log.info('Error from: %r Condition: %r', stanza.get_from(), err.get_condition)
def _send_message(self, message):
self.room_state.send_message(message)
def invite(self, buddy, message = None, callback = None):
room = self
try:
buddy = buddy.jid.as_unicode()
except:
buddy = JID(buddy).as_unicode()
if message is None:
message = _('You have been invited to %s') % self.jid.as_unicode()
m = Message(from_jid = room.protocol.self_buddy.jid, to_jid = room.jid)
x = m.xmlnode.newTextChild(None, 'x', None)
x.setNs(x.newNs('http://jabber.org/protocol/muc#user', None))
invite = x.newTextChild(None, 'invite', None)
invite.setProp('to', buddy)
reason = invite.newTextChild(None, 'reason', message)
self.protocol.send_cb(m, callback = callback)
invite = callsback(invite)
def send_typing_status(self, status):
pass
def set_subject(self, subject):
self.room_state.set_subject(subject)
def exit(self):
self.room_state.leave()
del self.protocol.conversations[self.jid.as_unicode()]
def self_buddy(self):
return self.protocol.self_buddy
self_buddy = property(self_buddy)
def _buddy(self, mucuser):
try:
return self.buddies[mucuser.nick]
except KeyError:
return self.buddies.setdefault(mucuser.nick, JabberChatBuddy(mucuser, self))